package com.lechuang.cunpinke.glide;

import android.content.Context;

import com.bumptech.glide.Glide;
import com.bumptech.glide.GlideBuilder;
import com.bumptech.glide.load.DecodeFormat;
import com.bumptech.glide.load.engine.bitmap_recycle.LruBitmapPool;
import com.bumptech.glide.load.engine.cache.DiskLruCacheFactory;
import com.bumptech.glide.module.GlideModule;
import com.lechuang.cunpinke.app.MyApplication;
import com.lechuang.cunpinke.manager.FolderManager;


/**
 * 作者：尹松涛
 * 邮箱：yinsongtaoshmily@outlook.com
 * 日期：2017/9/26
 * 时间：11:04
 */

public class InitModule implements GlideModule {

    @Override
    public void applyOptions(Context context, GlideBuilder builder) {

        int imageDiskCacheSize = 1024 * 1024 * 50;
        int bitmapLruCacheSize = (int) (Runtime.getRuntime().maxMemory() / 24);
        builder.setDecodeFormat(DecodeFormat.PREFER_RGB_565);
        builder.setBitmapPool(new LruBitmapPool(bitmapLruCacheSize));
        builder.setDiskCache(new DiskLruCacheFactory(FolderManager.getDiskCacheDir(MyApplication.getContext()), "imageCache", imageDiskCacheSize));
    }

    @Override
    public void registerComponents(Context context, Glide glide) {

    }
}
